package com.nc.gateway.service;

import java.util.Collection;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public interface RedisService {
    //单个删除
    void deleted(String key);
    //批量删除
    void deleted(Collection<String> keys);
    /**
     * 序列化key
     *
     * @param key
     * @return
     */
    byte[] dump(String key);
    /**
     * 是否存在key
     *
     * @param key
     * @return
     */
    Boolean hasKey(String key);
    /**
     * 设置过期时间
     *
     * @param key
     * @param timeout
     * @param unit
     * @return
     */
    Boolean expire(String key, long timeout, TimeUnit unit);

    Boolean expire(String key, Date date);
    /**
     * 查找匹配的key
     *
     * @param pattern
     * @return
     */
    Set<String> keys(String pattern);

    boolean set(String key, String value);

    boolean set(String key, String value, long time);

    String get(String key);
}
